package com.wh.testDanLi;

import org.springframework.util.ObjectUtils;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws Exception {
//        DanLiDemo2 instance = DanLiDemo2.getInstance();

//        Field wh = DanLiDemo2.class.getDeclaredField("wh");
//        wh.setAccessible(true);
//
//        Constructor<DanLiDemo2> declaredConstructor = DanLiDemo2.class.getDeclaredConstructor(null);
//        //设置Accessible的访问标志位为Ture，就可以通过反射获取私有变量的值，在访问时会忽略访问修饰符的检查
//        declaredConstructor.setAccessible(true);
//        DanLiDemo2 danLiDemoe = declaredConstructor.newInstance();
//        wh.set(danLiDemoe,false);
//        DanLiDemo2 instance = declaredConstructor.newInstance();
//        System.out.println(danLiDemoe==instance);
        DanLiDemo4 instance1 = DanLiDemo4.INSTANCE;
        Constructor<DanLiDemo4> declaredConstructor = DanLiDemo4.class.getDeclaredConstructor(null);
        declaredConstructor.setAccessible(true);
        DanLiDemo4 instance2 = declaredConstructor.newInstance();
        System.out.println(instance1);
        System.out.println(instance2);
    }
}
